﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.Security;

namespace iResume
{
    public partial class Resetpassword : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            string newpassword = newpass.Text;
            string confirmpass = confitxb.Text;


            //if (newpassword != confirmpass)
            //{
            //    Messagelbl3.Text = "do not match!";
            //}
            //else
            //{
            //    Messagelbl3.Text = "Match";
            //}

            //username.Text = Context.User.Identity.Name;

        }

        protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
        {
            string usertypes = (String)(Session["usertypes"]);
            string confirm = confitxb.Text;
            string email = (string)(Session["Email"]);

            string HashedPassword = "";
            //This is to hash the new password user have
            HashedPassword = FormsAuthentication.HashPasswordForStoringInConfigFile(confitxb.Text, "sha1");
            confitxb.Text = HashedPassword;


            if (usertypes == "Job Seeker")
            {

                DBManager.jsResetpassword(HashedPassword,email);
                Response.Redirect("loginpage.aspx");
            }
            if (usertypes == "Recruiter")
            {

                DBManager.rResetpassword(HashedPassword, email);
                Response.Redirect("loginpage.aspx");
            }
            if (usertypes == "Administrator")
            {

                DBManager.aResetpassword(HashedPassword, email);
                Response.Redirect("loginpage.aspx");
            }

        }
    }
}